//
//  XWXSqliteModelTool.h
//  XWXSqlite
//
//  Created by 许卫星 on 17/9/4.
//  Copyright © 2017年 wxxu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "XWXSqliteQueryCommand.h"

@interface XWXSqliteQueryCommandTool : NSObject
#pragma mark - 查询语句

/**
 查询所有数据，默认不去重
 @param cls    数据对象
 @param dbName 数据库名

 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)selectWithModelClass: (Class)cls withDBName: (NSString *)dbName;

/**
 查询所有数据

 @param cls    数据对象
 @param dbName 数据库名
 @param isDistinct 是否去重

 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)selectWithModelClass: (Class)cls withDBName: (NSString *)dbName isDistinct:(BOOL)isDistinct;

/**
 查询指定字段数据数据

 @param cls        数据对象
 @param dbName     数据库名
 @param columList  指定的字段，多个用,隔开 如：name,age
 @param isDistinct 是否去重

 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)selectWithModelClass: (Class)cls withDBName: (NSString *)dbName columList:(NSString *)columList isDistinct:(BOOL)isDistinct;

/**
 查询指定字段数据数据

 @param cls          数据对象
 @param dbName       数据库名
 @param columList    指定的字段，多个用,隔开 如：name,age
 @param columnName   where条件字段
 @param relationType 关系 > <  =  >=  <=
 @param value        where条件值
 @param isDistinct   是否去重

 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)selectWithModelClass: (Class)cls withDBName: (NSString *)dbName columList:(NSString *)columList columnName:(NSString *)columnName relation:(ColumnNameToValueRelationType)relationType value:(id)value isDistinct:(BOOL)isDistinct;

#pragma mark - 表格
/**
 创建表格
 @param cls    需要保存的模型类
 @param dbName 需要保存到哪个库，使用默认库传nil
 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)createTableWithModelClass: (Class)cls withDBName: (NSString *)dbName;
//创建一个临时表格表格
+ (XWXSqliteQueryCommand *)createTempTableWithModelClass: (Class)cls withDBName: (NSString *)dbName;
/**
 删除表格

 @param cls    数据模型类
 @param dbName 数据库名称，使用默认库传nil

 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)dropTableWithModelClass: (Class)cls withDBName: (NSString *)dbName;
+ (XWXSqliteQueryCommand *)dropTableWithTableName: (NSString *)tableName withDBName: (NSString *)dbName;
#pragma mark - UID语句
/**
 插入数据
 
 @param model    数据模型类
 @param dbName 数据库名称，使用默认库传nil
 
 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)insertWithModel: (id)model withDBName: (NSString *)dbName;

/**
 更新数据
 
 @param model    数据模型类
 @param dbName 数据库名称，使用默认库传nil
 @param condition       更新条件
 
 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)updateWithModel: (id)model withDBName: (NSString *)dbName whereCondition:(NSString *)condition;
+ (XWXSqliteQueryCommand *)updateWithModel: (id)model withDBName: (NSString *)dbName columnName:(NSString *)columnName relation:(ColumnNameToValueRelationType)relationType value:(id)value;
/**
 删除表
 
 @param cls    数据模型类
 @param dbName 数据库名称，使用默认库传nil
  @param condition       删除条件
 
 @return Sql对象
 */
+ (XWXSqliteQueryCommand *)deleteWithModelClass: (Class)cls withDBName: (NSString *)dbName whereCondition:(NSString *)condition;
+ (XWXSqliteQueryCommand *)deleteWithModelClass: (Class)cls withDBName: (NSString *)dbName columnName:(NSString *)columnName relation:(ColumnNameToValueRelationType)relationType value:(id)value;

@end
